package com.hk.admin.common.util;

import com.hk.admin.common.base.dto.message.Message;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import static com.hk.admin.common.base.dto.message.MessageErrorCode.*;

/**
 * <br>
 * <b>功能：</b>消息工具类<br>
 * <b>作者：</b>Pan.ShiJu<br>
 * <b>日期：</b>2017/6/1 17:46<br>
 */
public class MessageUtil {

    /**
     * 返回参数检查错误信息
     */
    public static ResponseEntity<Message> error(String errorMsg) {
        return new ResponseEntity<>(new Message(ERROR_HK_ADMIN, errorMsg, null), HttpStatus.OK);
    }

    /**
     * 错误提示信息
     */
    public static ResponseEntity<Message> error(Integer errorCode, String errorMsg) {
        return new ResponseEntity<>(new Message(errorCode, errorMsg, null), HttpStatus.OK);
    }

    /**
     * 返回正确信息
     *
     * @param msg
     * @return
     */
    public static ResponseEntity<Message> success(Object msg) {
        return new ResponseEntity<>(new Message(SUCCESS_CODE, SUCCESS_MSG, msg), HttpStatus.OK);
    }


    /**
     * 系统错误
     */
    public static ResponseEntity<Message> errorInternalServer(String errorMsg) {
        return new ResponseEntity<>(new Message(ERROR_HK_ADMIN, errorMsg, null), HttpStatus.INTERNAL_SERVER_ERROR);
    }

    /**
     * 系统错误
     */
    public static ResponseEntity<Message> errorInternalServer(Integer errorCode, String errorMsg) {
        return new ResponseEntity<>(new Message(errorCode, errorMsg, null), HttpStatus.INTERNAL_SERVER_ERROR);
    }

}
